namespace Asmex.FileViewer
{
    using Asmex.ObjViewer;
    using System;
    using System.IO;

    public class SectionHeader : Region
    {
        private uint _Characteristics;
        private uint _Misc;
        private string _Name;
        private ushort _NumberOfLinenumbers;
        private ushort _NumberOfRelocations;
        private uint _PointerToLinenumbers;
        private uint _PointerToRawData;
        private uint _PointerToRelocations;
        private uint _SizeOfRawData;
        private uint _VirtualAddress;

        public SectionHeader(BinaryReader reader)
        {
            base.Start = reader.BaseStream.Position;
            base.Length = 40L;
            for (int i = 0; i < 8; i++)
            {
                byte num2 = reader.ReadByte();
                if (num2 != 0)
                {
                    this._Name = this._Name + ((char) num2);
                }
            }
            this._Misc = reader.ReadUInt32();
            this._VirtualAddress = reader.ReadUInt32();
            this._SizeOfRawData = reader.ReadUInt32();
            this._PointerToRawData = reader.ReadUInt32();
            this._PointerToRelocations = reader.ReadUInt32();
            this._PointerToLinenumbers = reader.ReadUInt32();
            this._NumberOfRelocations = reader.ReadUInt16();
            this._NumberOfLinenumbers = reader.ReadUInt16();
            this._Characteristics = reader.ReadUInt32();
        }

        public override string ToString()
        {
            string[] strArray = new string[] { base.ToString(), " ", this.Name, " raw data at offsets {", this.PointerToRawData.ToString("X8"), " - ", (this.PointerToRawData + this.SizeOfRawData).ToString("X8"), "}" };
            return string.Concat(strArray);
        }

        [ObjViewer(Hex=true)]
        public uint Characteristics
        {
            get
            {
                return this._Characteristics;
            }
        }

        public uint Misc
        {
            get
            {
                return this._Misc;
            }
        }

        public string Name
        {
            get
            {
                return this._Name;
            }
        }

        public ushort NumberOfLinenumbers
        {
            get
            {
                return this._NumberOfLinenumbers;
            }
        }

        public ushort NumberOfRelocations
        {
            get
            {
                return this._NumberOfRelocations;
            }
        }

        [ObjViewer(Hex=true)]
        public uint PointerToLinenumbers
        {
            get
            {
                return this._PointerToLinenumbers;
            }
        }

        [ObjViewer(Hex=true)]
        public uint PointerToRawData
        {
            get
            {
                return this._PointerToRawData;
            }
        }

        [ObjViewer(Hex=true)]
        public uint PointerToRelocations
        {
            get
            {
                return this._PointerToRelocations;
            }
        }

        public uint SizeOfRawData
        {
            get
            {
                return this._SizeOfRawData;
            }
        }

        [ObjViewer(Hex=true)]
        public uint VirtualAddress
        {
            get
            {
                return this._VirtualAddress;
            }
        }
    }
}
